home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 25 / AMIGAplus Sonderheft 25 (2000)(Falke)(DE)(Track 1 of 4)[!].iso / Updates / HD-Installer / jst_dev / sources / src / DiskTools / gremdecode.asm < prev    next >
Assembly Source File  |  2000-04-12  |  3KB  |  178 lines

  1.     XDEF    _DecodeTrack
  2.  
  3. GET_D0D1:MACRO
  4.     movem.l    D3-D4,-(sp)
  5.     move.l    (A0)+,D0    ; higher part (dest register)
  6.     move.l    (A0),D3
  7.     lsr.l    D6,D3        ; shift lower part with count
  8.     moveq    #$20,D4
  9.     sub.l    D6,D4
  10.     lsl.l    D4,D0        ;higher part has to be shifted to fill
  11.     or.l    D3,D0        ;the rest-place, a longword has 20 bits
  12.     movem.l    (sp)+,D3-D4    
  13.     move.w    D0,D1
  14.     swap    D0
  15.     ENDM
  16.  
  17. asmtest:
  18.     move.l    #dectrack,A0
  19.     move.l    #rawtrack,D0
  20.     bsr    DecodeTrack
  21.     rts
  22.  
  23. ; *** finds sync and shift
  24.  
  25. ; in A0 rawdata
  26. ; out: D0 = 0 if success
  27. ;      D1 = shift (0-15)
  28.  
  29. GetSync:
  30.     movem.l    D2-D6/A1-A6,-(sp)
  31.  
  32.     MOVE.L    A0,A2
  33.     lea    $7C00(A2),A4        ;end of rawtrack
  34.  
  35. .SHF2    MOVEQ.L    #$10-1,D5
  36.  
  37.     ; *** try to find the sync shift (0 to 15)
  38.  
  39. .SHF1    MOVE.L    (A2),D0        ; a longword of data
  40.     LSR.L    D5,D0        ; shift it by D5
  41.     CMP.W    #$4489,D0    ; sync?
  42.     BEQ.S    .SY        ; yes: found sync AND shift
  43.     DBF    D5,.SHF1
  44.     ADDQ.L    #2,A2
  45.     cmp.l    A2,A4
  46.     beq    ErrorSyn
  47.     BRA.S    .SHF2
  48.  
  49.     ; ** shift has been found, sync too.
  50.  
  51. .SY    MOVE.L    (A2),D0
  52.     ADDQ.L    #2,A2
  53.     LSR.L    D5,D0            ;d5 is the shifting-number when sync was found
  54.     CMP.W    #$4489,D0
  55.     BNE.S    .SY
  56.  
  57. .1    MOVE.L    (A2),D0
  58.     ADDQ.L    #2,A2
  59.     LSR.L    D5,D0
  60.     CMP.W    #$4489,D0
  61.     BEQ.S    .1
  62.  
  63.     moveq    #0,D0
  64.     move.l    A2,A0    ; buffer synced
  65.     move.l    D5,D1    ; shift
  66.     bra    ExitSyn
  67.  
  68. ErrorSyn:
  69.     moveq    #-1,D0
  70. ExitSyn
  71.     movem.l    (sp)+,D2-D6/A1-A6
  72.     rts
  73.  
  74. _DecodeTrack:
  75.     move.l    4(sp),D0
  76.     move.l    8(sp),A0
  77. DecodeTrack
  78.     movem.l    D1-A6,-(sp)
  79.  
  80.     move.l    A0,A1    ; dec
  81.     move.l    D0,A0    ; raw
  82.  
  83.     bsr    GetSync
  84.     tst.l    D0
  85.     bne    syncerr
  86.  
  87.     lea    $7FFE(A0),A2
  88.  
  89.     move.l    D1,D6        ; shift : D6
  90.  
  91.     subq.l    #2,A0        ; longword reader
  92.  
  93.     ; *** until $5555 met
  94.  
  95. LB_C962
  96.     MOVE.L    (A0),D0        ; read word
  97.     addq.l    #2,A0
  98.     lsr.l    D6,D0        ; shift
  99.  
  100.     cmp.l    A0,A2
  101.     beq    decodeerr
  102.  
  103.     CMP.W    #$5555,D0
  104.     BNE.B    LB_C962        ; until ==$5555
  105.  
  106.  
  107.     MOVE.W    #$0BFF,D7
  108.     MOVE.W    #$5555,D2
  109.     moveq    #0,D3
  110.  
  111.     subq.l    #2,A0
  112. decodeloop
  113.     ; boucle executee $C00 fois (*2=$1800: 1 track)
  114.  
  115.     GET_D0D1
  116.  
  117. ;    MOVE.W    (A0)+,D0    ; read word
  118. ;    MOVE.W    (A0)+,D1    ; read word
  119.  
  120.     AND.W    D2,D0
  121.     AND.W    D2,D1
  122.     ADD.W    D1,D1
  123.     ADD.W    D0,D1
  124.     MOVE.W    D1,(A1)+    ; write word
  125.     ADD.W    D1,D3
  126.  
  127.     ; SNIP
  128.  
  129.  
  130.     DBF    D7,decodeloop
  131.  
  132. ;    MOVE.W    (A0)+,D0    ; read word
  133. ;    MOVE.W    (A0)+,D1    ; read word
  134.  
  135.     GET_D0D1
  136.  
  137.     AND.W    D2,D0
  138.     AND.W    D2,D1
  139.     ADD.W    D1,D1
  140.     ADD.W    D0,D1
  141.     MOVE.W    D1,D7
  142.  
  143.     cmp.w    D3,D7
  144.     bne    decodeerr
  145.  
  146.     movem.l    (sp)+,D1-A6
  147.     moveq    #0,D0
  148.     RTS    
  149.  
  150.     ; ** garbage
  151.  
  152. ;    MOVE.W    (A0)+,D0    ; read word
  153. ;    MOVE.W    (A0)+,D1    ; read word
  154.  
  155.     GET_D0D1
  156.  
  157.     AND.W    D2,D0
  158.     AND.W    D2,D1
  159.     ADD.W    D1,D1
  160.     ADD.W    D0,D1
  161.     MOVE.W    D1,D6
  162.  
  163. syncerr:
  164.     movem.l    (sp)+,D1-A6
  165.     moveq    #-2,D0
  166.     rts
  167.  
  168. decodeerr:
  169.     movem.l    (sp)+,D1-A6
  170.     moveq    #-1,D0
  171.     rts
  172.  
  173. dectrack:
  174. ;    blk.b    $1900,0
  175. rawtrack:
  176. ;    incbin    "sb2.raw"
  177.  
  178.